package com.ruoyi.web.controller.Tour;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TourVideo;
import com.ruoyi.system.service.ITourVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * vlog管理Controller
 *
 * @author once
 * @date 2020-10-02
 */
@RestController
@RequestMapping("/Tour/video")
public class TourVideoController extends BaseController
{
    @Autowired
    private ITourVideoService tourVideoService;

    /**
     * 查询vlog管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourVideo tourVideo)
    {
        startPage();
        List<TourVideo> list = tourVideoService.selectTourVideoList(tourVideo);
        return getDataTable(list);
    }

    /**
     * 导出vlog管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:video:export')")
    @Log(title = "vlog管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourVideo tourVideo)
    {
        List<TourVideo> list = tourVideoService.selectTourVideoList(tourVideo);
        ExcelUtil<TourVideo> util = new ExcelUtil<TourVideo>(TourVideo.class);
        return util.exportExcel(list, "video");
    }

    /**
     * 获取vlog管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('Tour:video:query')")
    @GetMapping(value = "/{videoId}")
    public AjaxResult getInfo(@PathVariable("videoId") Long videoId)
    {
        return AjaxResult.success(tourVideoService.selectTourVideoById(videoId));
    }

    /**
     * 新增vlog管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:video:add')")
    @Log(title = "vlog管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourVideo tourVideo)
    {
        return toAjax(tourVideoService.insertTourVideo(tourVideo));
    }

    /**
     * 修改vlog管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:video:edit')")
    @Log(title = "vlog管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourVideo tourVideo)
    {
        return toAjax(tourVideoService.updateTourVideo(tourVideo));
    }

    /**
     * 删除vlog管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:video:remove')")
    @Log(title = "vlog管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoIds}")
    public AjaxResult remove(@PathVariable Long[] videoIds)
    {
        return toAjax(tourVideoService.deleteTourVideoByIds(videoIds));
    }
}
